package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonUnitBean;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;
import com.fancy.learncenter.ui.callback.AlbumImpl;

import java.util.List;

/**
 * Created by shiweiwei on 2018/1/5.
 */

public class CartoonUnitAdapter extends CommonRecycleViewAdapter<CartoonUnitBean>{

    public void setListener(AlbumImpl listener) {
        this.listener = listener;
    }

    private AlbumImpl listener;
    public CartoonUnitAdapter(Context mContext, List<CartoonUnitBean> itemDatas) {
        super(mContext, R.layout.cartoon_unit_item_layout, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, CartoonUnitBean item, final int position) {

        TextView unitName = customViewHold.getView(R.id.unit_name);
        if (!TextUtils.isEmpty(item.getUnitName())) {
            unitName.setText(item.getUnitName());
        }

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (listener != null){
                    listener.onClick(position);
                }

            }
        });
    }
}
